home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / muds / pennmush.000 / pennmush-1.50-p8-linux.tar / pennmush / cque.c < prev    next >
C/C++ Source or Header  |  1993-02-16  |  18KB  |  771 lines

  1. /* cque.c */
  2.  
  3. #include <ctype.h>
  4. #include <fcntl.h>
  5. #include <string.h>
  6. #ifdef XENIX
  7. #include <sys/signal.h>
  8. #else
  9. #include <signal.h>
  10. #endif                /* xenix */
  11.  
  12. #include "config.h"
  13. #include "db.h"
  14. #include "interface.h"
  15. #include "match.h"
  16. #include "externs.h"
  17.  
  18. #ifdef MEM_CHECK
  19. #include "mem_check.h"
  20. #endif
  21.  
  22. extern char ccom[];
  23. extern dbref cplr;
  24.  
  25. extern int atoi();
  26.  
  27. typedef struct bque BQUE;
  28.  
  29. struct bque {
  30.   BQUE *next;
  31.   dbref player;            /* player who will do command */
  32.   dbref cause;            /* player causing command (for %N) */
  33.   dbref sem;            /* semaphore object to block on */
  34.   int left;            /* seconds left until execution */
  35.   char *env[10];        /* environment, from wild match */
  36.   char *comm;            /* command to be executed */
  37. };
  38.  
  39. static BQUE *qfirst = NULL, *qlast = NULL, *qwait = NULL;
  40. static BQUE *qlfirst = NULL, *qllast = NULL;
  41. static BQUE *qsemfirst = NULL, *qsemlast = NULL;
  42.  
  43. void parse_que(player, command, cause)
  44.     dbref player;
  45.     char *command;
  46.     dbref cause;  /* cause is needed to determine priority */
  47. {
  48.   char buff[BUFFER_LEN], *s, *r;
  49.   void big_que();
  50.   s = buff;
  51.   strcpy(buff, command);
  52.   while ((r = parse_to(&s, ';', 0)) != NULL)
  53.     big_que(player, r, cause);
  54. }
  55.  
  56. static int add_to_generic(player, am, key)
  57.      dbref player;
  58.      int am;
  59.      int key;            /* 0 for queue, 1 for semaphore */
  60. {
  61.   int num = 0;
  62.   ATTR *a;
  63.   const char *atrname;
  64.   char buff[MAX_COMMAND_LEN];
  65.  
  66.   if (key == 0) {
  67.     atrname = "QUEUE";
  68.     player = Owner(player);
  69.   } else {
  70.     atrname = "SEMAPHORE";
  71.   }
  72.  
  73.   a = atr_get_noparent(player, atrname); /* don't get from the parent! */
  74.   if (a)
  75.     num = atoi(uncompress(a->value));
  76.   num += am;
  77.  
  78.   if (num)
  79.     sprintf(buff, "%d", num);
  80.   else
  81.     *buff = '\0';
  82.  
  83.   (void) atr_add(player, atrname, buff, GOD, NOTHING);
  84.   return (num);
  85. }
  86.  
  87. static int add_to(player, am)
  88.     dbref player;
  89.     int am;
  90. {
  91.   return (add_to_generic(player, am, 0));
  92. }
  93.  
  94. static int add_to_sem(player, am)
  95.      dbref player;
  96.      int am;
  97. {
  98.   return (add_to_generic(player, am, 1));
  99. }
  100.  
  101. static int queue_limit(player)
  102.      dbref player;
  103. {
  104.   /* returns 1 if player has exceeded his queue limit */
  105.  
  106.   if (HugeQueue(player)) {
  107.     if (add_to(player, 1) > (10 * QUEUE_QUOTA))
  108.       return 1;
  109.     else
  110.       return 0;
  111.   } else {
  112.     if (add_to(player, 1) > QUEUE_QUOTA)
  113.       return 1;
  114.     else 
  115.       return 0;
  116.   }
  117.   return 0;            /* NOTREACHED */
  118. }
  119.  
  120. void free_qentry(point)
  121.      BQUE *point;
  122. {
  123.   int a;
  124.  
  125.   for (a = 0; a < 10; a++)
  126.     if (point->env[a]) {
  127.       free((char *)point->env[a]);
  128. #ifdef MEM_CHECK
  129.       del_check("bqueue_env");
  130. #endif
  131.     }
  132.   if (point->comm)
  133.     free((char *)point->comm);
  134.   free((char *)point);
  135. #ifdef MEM_CHECK
  136.   del_check("bqueue_comm");
  137.   del_check("bqueue");
  138. #endif
  139. }
  140.  
  141. void big_que(player, command, cause)
  142.     dbref player;
  143.     char *command;
  144.     dbref cause;
  145. {
  146.   int a;
  147.   BQUE *tmp;
  148.  
  149.   if ((Typeof(player) != TYPE_PLAYER) && (Halted(player)))
  150.     return;
  151.   /* make sure player can afford to do it */
  152.   if (!payfor(player, QUEUE_COST + (((random() & QUEUE_LOSS) == 0) ? 1 : 0))) {
  153.     notify(Owner(player), "Not enough money to queue command.");
  154.     return;
  155.   }
  156.   if (queue_limit(player)) {
  157.     notify(Owner(player),
  158.        tprintf("Runaway object: %s(#%d). Commands halted.",
  159.            Name(player), player));
  160.     /* wipe out that object's queue and set it HALT */
  161.     do_halt(Owner(player), "", player);
  162.     Flags(player) |= HALT;
  163.     return;
  164.   }
  165.   tmp = (BQUE *) malloc (sizeof(BQUE));
  166.   strcpy((tmp->comm = (char *) malloc(strlen(command)+1)), command);
  167. #ifdef MEM_CHECK
  168.   add_check("bqueue");
  169.   add_check("bqueue_comm");
  170. #endif
  171.   tmp->player = player;
  172.   tmp->next = NULL;
  173.   tmp->left = 0;
  174.   tmp->cause = cause;
  175.   for (a = 0; a < 10; a++)
  176.     if (!wptr[a])
  177.       tmp->env[a] = NULL;
  178.     else {
  179.       strcpy((tmp->env[a] = (char *)malloc(strlen(wptr[a])+1)), wptr[a]);
  180. #ifdef MEM_CHECK
  181.       add_check("bqueue_env");
  182. #endif
  183.     }
  184.   if (Typeof(cause) == TYPE_PLAYER) {
  185.     if (qlast) {
  186.       qlast->next = tmp;
  187.       qlast = tmp;
  188.     } else
  189.       qlast = qfirst = tmp;
  190.   } else {
  191.     if (qllast) {
  192.       qllast->next = tmp;
  193.       qllast = tmp;
  194.     } else
  195.       qllast = qlfirst = tmp;
  196.   }
  197. }
  198.  
  199. void wait_que(player, wait, command, cause, sem)
  200.     dbref player;
  201.     int wait;
  202.     char *command;
  203.     dbref cause;
  204.     dbref sem;
  205. {
  206.   BQUE *tmp;
  207.   int a;
  208.   /* make sure player can afford to do it */
  209.   if (!payfor(player, QUEUE_COST + (((random() & QUEUE_LOSS) == 0) ? 1 : 0))) {
  210.     notify(player, "Not enough money to queue command.");
  211.     return;
  212.   }
  213.   tmp = (BQUE *)malloc(sizeof(BQUE));
  214.   strcpy((tmp->comm = (char *)malloc(strlen(command)+1)), command);
  215. #ifdef MEM_CHECK
  216.   add_check("bqueue");
  217.   add_check("bqueue_comm");
  218. #endif
  219.   tmp->player = player;
  220.   tmp->cause = cause;
  221.   tmp->sem = sem;
  222.   tmp->left = wait;
  223.  
  224.   for (a = 0; a < 10; a++) {
  225.     if (!wptr[a])
  226.       tmp->env[a] = NULL;
  227.     else {
  228.       strcpy((tmp->env[a] = (char *)malloc(strlen(wptr[a])+1)), wptr[a]);
  229. #ifdef MEM_CHECK
  230.       add_check("bqueue_env");
  231. #endif
  232.     }
  233.   }
  234.  
  235.   if (sem == NOTHING) {
  236.     /* No semaphore, put on normal wait queue */
  237.     tmp->next = qwait;
  238.     qwait = tmp;
  239.   } else {
  240.     /* Put it on the semaphore queue */
  241.     tmp->next = NULL;
  242.     if (qsemlast != NULL)
  243.       qsemlast->next = tmp;
  244.     else
  245.       qsemfirst = tmp;
  246.     qsemlast = tmp;
  247.   }
  248.  
  249. }
  250.  
  251. void do_second()
  252. {
  253.   /* call every second to check for wait queue commands */
  254.  
  255.   BQUE *trail = NULL, *point, *next;
  256.   int a;
  257.  
  258.   /* move contents of low priority queue onto end of normal one 
  259.    * this helps to keep objects from getting out of control since 
  260.    * its effects on other objects happen only after one second 
  261.    * this should allow @halt to be typed before getting blown away 
  262.    * by scrolling text.
  263.    */
  264.  
  265.   if (qlfirst) {
  266.     if (qlast)
  267.       qlast->next = qlfirst;
  268.     else
  269.       qfirst = qlfirst;
  270.     qlast = qllast;
  271.     qllast = qlfirst = NULL;
  272.   }
  273.  
  274.   /* check regular wait queue */
  275.  
  276.   for (point = qwait, trail = NULL; point; point = next) {
  277.     /*
  278.      * Note: this would be 0 except the command is being put in the low
  279.      * priority queue to be done in one second anyways
  280.      */
  281.     if (point->left-- <= 1) {
  282.       if (trail != NULL)
  283.     trail->next = next = point->next;
  284.       else
  285.     qwait = next = point->next;
  286.       giveto(point->player, QUEUE_COST);
  287.       for (a = 0; a < 10; a++) {
  288.     wptr[a] = point->env[a];
  289.       }
  290.       parse_que(point->player, point->comm, point->cause);
  291.       free_qentry(point);
  292.     } else
  293.       next = (trail = point)->next;
  294.   }
  295.  
  296.   /* check for semaphore timeouts */
  297.  
  298.   for (point = qsemfirst, trail = NULL; point; point = next) {
  299.     if (point->left < 0) {
  300.       next = (trail = point)->next;
  301.       continue;            /* skip non-timed waits */
  302.     }
  303.     if (point->left-- <= 1) {
  304.       if (trail != NULL)
  305.     trail->next = next = point->next;
  306.       else
  307.     qsemfirst = next = point->next;
  308.       if (point == qsemlast)
  309.     qsemlast = trail;
  310.       giveto(point->player, QUEUE_COST);
  311.       add_to_sem(point->sem, -1);
  312.       point->sem = NOTHING;
  313.       for (a = 0; a < 10; a++) {
  314.     wptr[a] = point->env[a];
  315.       }
  316.       parse_que(point->player, point->comm, point->cause);
  317.       free_qentry(point);
  318.     } else
  319.       next = (trail = point)->next;
  320.   }
  321. }
  322.  
  323. int test_top()
  324. {
  325.   return (qfirst ? 1 : 0);
  326. }
  327.  
  328. /* execute one command off the top of the queue */
  329. int do_top()
  330. {
  331.   int a;
  332.   int i = 0;
  333.   BQUE *tmp;
  334.   dbref player;
  335.   char tbuf1[BUFFER_LEN], tbuf2[BUFFER_LEN];
  336.   char tbuf3[BUFFER_LEN], *s;
  337.  
  338.   if (!qfirst)
  339.     return (0);
  340.   if (qfirst->player && !Going(qfirst->player)) {
  341.     giveto(qfirst->player, QUEUE_COST);
  342.     cplr = qfirst->player;
  343.     strcpy(ccom, qfirst->comm);
  344.     add_to(player = qfirst->player, -1);
  345.     qfirst->player = 0;
  346.     if ((Typeof(player) == TYPE_PLAYER) || !Halted(player)) {
  347.       for (a = 0; a < 10; a++) {
  348.     wptr[a] = qfirst->env[a];
  349.       }
  350.       strcpy(tbuf2, uncompress(qfirst->comm));
  351.       tbuf3[0] = '\0';
  352.       for (s = tbuf2; *s; tbuf3[i++] = toupper(*s++)) ;
  353.       tbuf3[i++] = '\0';
  354.       strcpy(tbuf1, tbuf2);
  355.       process_command(player, tbuf1, qfirst->cause, 0);
  356.     }
  357.   }
  358.   tmp = qfirst->next;
  359.   free_qentry(qfirst);
  360.   if (!(qfirst = tmp))
  361.     qlast = NULL;
  362.   return (1);
  363. }
  364.  
  365. int nfy_que(sem, key, count)
  366.      dbref sem;
  367.      int key;            /* 0 is normal, 1 is all, 2 is drain */
  368.      int count;
  369. {
  370.   BQUE *point, *trail, *next;
  371.   int num;
  372.   ATTR *a;
  373.   int x;
  374.  
  375.   a = atr_get_noparent(sem, "SEMAPHORE");
  376.   if (a)
  377.     num = atoi(uncompress(a->value));
  378.   else
  379.     num = 0;
  380.   if (num > 0) {
  381.     num = 0;
  382.     for (point = qsemfirst, trail = NULL; point; point = next) {
  383.       if (point->sem == sem) {
  384.     num++;
  385.     if (trail)
  386.       trail->next = next = point->next;
  387.     else
  388.       qsemfirst = next = point->next;
  389.     if (point == qsemlast)
  390.       qsemlast = trail;
  391.  
  392.     /* run or discard the command */
  393.     giveto(point->player, QUEUE_COST);
  394.     for (x = 0; x < 10; x++)
  395.       wptr[x] = point->env[x];
  396.     if (key != 2)
  397.       parse_que(point->player, point->comm, point->cause);
  398.     else
  399.       free_qentry(point);
  400.  
  401.       } else {
  402.     next = (trail = point)->next;
  403.       }
  404.  
  405.       /* if we've notified enough, exit. Note that we don't have to check
  406.        * for the case of @notify/all, since we don't break out of this
  407.        * loop "manually" unless the key is standard @notify.
  408.        */
  409.       if ((key == 0) && (num >= count))
  410.     next = NULL;
  411.     }
  412.   } else {
  413.     num = 0;
  414.   }
  415.  
  416.   /* update the semaphore waiter's count */
  417.   if (key == 0)
  418.     add_to_sem(sem, -count);
  419.   else
  420.     atr_add(sem, "SEMAPHORE", "", GOD, NOTHING);
  421.  
  422.   return num;
  423. }
  424.  
  425. void do_notify(player, cause, key, what, count)
  426.      dbref player;
  427.      dbref cause;
  428.      int key;            /* 0 is normal, 1 is all, 2 is drain */
  429.      char *what;
  430.      char *count;
  431. {
  432.   dbref thing;
  433.   int i;
  434.  
  435.   /* find it */
  436.   init_match(player, what, NOTYPE);
  437.   match_everything();
  438.   if ((thing = noisy_match_result()) == NOTHING)
  439.     return;
  440.  
  441.   /* must control something or have it link_ok in order to use it as 
  442.    * as a semaphore.
  443.    */
  444.   if (!controls(player, thing) && !LinkOk(thing)) {
  445.     notify(player, "Permission denied.");
  446.     return;
  447.   }
  448.  
  449.   /* find how many times to notify */
  450.   if (count && *count)
  451.     i = atoi(count);
  452.   else
  453.     i = 1;
  454.  
  455.   if (i > 0)
  456.     nfy_que(thing, key, i);
  457.  
  458.   if (key != 2) {
  459.     quiet_notify(player, "Notified.");
  460.   } else {
  461.     quiet_notify(player, "Drained.");
  462.   }
  463. }
  464.  
  465. void do_wait(player, cause, arg1, cmd)
  466.      dbref player;
  467.      dbref cause;
  468.      char *arg1;
  469.      char *cmd;
  470. {
  471.     dbref thing;
  472.     char *tcount;
  473.     int waitfor, num;
  474.     ATTR *a;
  475.     char *arg2;
  476.  
  477.     arg2 = strip_braces(cmd);
  478.  
  479.     if (is_number(arg1)) {
  480.     /* normal wait */
  481.     wait_que(player, atoi(arg1), arg2, cause, NOTHING);
  482.     free(arg2);
  483.     return;
  484.     }
  485.  
  486.     /* semaphore wait with optional timeout */
  487.  
  488.     /* find the thing to wait on */
  489.     tcount = (char *) index(arg1, '/');
  490.     if (tcount)
  491.     *tcount++ = '\0';
  492.     init_match(player, arg1, NOTYPE);
  493.     match_everything();
  494.     if ((thing = noisy_match_result()) == NOTHING) {
  495.     free(arg2);
  496.     return;
  497.     }
  498.  
  499.     if (!controls(player, thing) && !LinkOk(thing)) {
  500.     notify(player, "Permission denied.");
  501.     free(arg2);
  502.     return;
  503.     }
  504.  
  505.     /* get timeout, default of -1 */
  506.     if (tcount && *tcount)
  507.     waitfor = atol(tcount);
  508.     else
  509.     waitfor = -1;
  510.  
  511.     add_to_sem(thing, 1);
  512.     a = atr_get_noparent(thing, "SEMAPHORE");
  513.     if (a)
  514.     num = atoi(uncompress(a->value));
  515.     else
  516.     num = 0;
  517.     if (num <= 0) {
  518.     thing = NOTHING;
  519.     waitfor = -1;        /* just in case there was a timeout given */
  520.     }
  521.     wait_que(player, waitfor, arg2, cause, thing);
  522.     free(arg2);
  523. }
  524.  
  525. void do_queue(player, what)
  526.     dbref player;
  527.     const char *what;
  528. {
  529.   /* tell player what commands they have pending in the queue (@ps) */
  530.  
  531.   BQUE *tmp;
  532.   dbref victim = NOTHING;
  533.   int everything = 0;
  534.   int quick = 0;
  535.   int pq = 0, oq = 0, wq = 0, sq = 0;
  536.   int tpq = 0, toq = 0, twq = 0, tsq = 0;
  537.  
  538.   if (!strcasecmp(what, "count")) {
  539.     victim = player;
  540.     everything = 1;
  541.     quick = 1;
  542.   }
  543.   else if (LookQueue(player)) {
  544.     if(!what || !*what)
  545.       victim = player;
  546.     else
  547.       if(!strcasecmp(what, "all")) { /* do the whole thing */
  548.         victim = player;
  549.         everything = 1;
  550.       } else {
  551.         init_match(player, what, TYPE_PLAYER);
  552.         match_player();
  553.         match_absolute();
  554.         match_me();
  555.         victim = match_result();
  556.       }
  557.   } else {
  558.     victim = player;
  559.   }
  560.  
  561.   switch(victim) {
  562.     case NOTHING:
  563.       notify(player, "I couldn't find that player.");
  564.       break;
  565.     case AMBIGUOUS:
  566.       notify(player, "I don't know who you mean!");
  567.       break;
  568.     default:
  569.       if(everything == 1)
  570.         notify(player, "Queue for : all");
  571.       else
  572.         notify(player, tprintf("Queue for : %s", db[victim].name));
  573.  
  574.       if (!quick) notify(player,"Player Queue:");
  575.       for (tmp = qfirst; tmp; tmp = tmp->next) {
  576.     tpq++;
  577.     if ((Owner(tmp->player) == Owner(victim)) || (everything)) {
  578.       pq++;
  579.       if (!quick)
  580.           notify(player, tprintf("%s:%s", unparse_object(player, tmp->player),
  581.                  tmp->comm));
  582.     }
  583.       }
  584.  
  585.       if (!quick) notify(player,"Object Queue:");
  586.       for (tmp = qlfirst; tmp; tmp = tmp->next) {
  587.     toq++;
  588.     if ((Owner(tmp->player) == Owner(victim)) || (everything)) {
  589.       oq++;
  590.       if (!quick)
  591.           notify(player, tprintf("%s:%s", unparse_object(player, tmp->player),
  592.                  tmp->comm));
  593.     }
  594.       }
  595.  
  596.       if (!quick) notify(player, "Wait Queue:");
  597.       for (tmp = qwait; tmp; tmp = tmp->next) {
  598.     twq++;
  599.     if ((Owner(tmp->player) == Owner(victim)) || (everything)) {
  600.       wq++;
  601.       if (!quick)
  602.           notify(player, tprintf("[%d]%s:%s", tmp->left,
  603.                  unparse_object(player, tmp->player),
  604.                  tmp->comm));
  605.     }
  606.       }
  607.  
  608.       if (!quick) notify(player, "Semaphore Queue:");
  609.       for (tmp = qsemfirst; tmp; tmp = tmp->next) {
  610.     tsq++;
  611.     if ((Owner(tmp->player) == Owner(victim)) || (everything)) {
  612.       sq++;
  613.       if (!quick) {
  614.         if (tmp->left != -1)
  615.           notify(player, tprintf("[#%d/%d]%s:%s", tmp->sem, tmp->left,
  616.                      unparse_object(player, tmp->player),
  617.                      tmp->comm));
  618.         else
  619.           notify(player, tprintf("[#%d]%s:%s", tmp->sem,
  620.                      unparse_object(player, tmp->player),
  621.                      tmp->comm));
  622.       }
  623.     }
  624.       }
  625.  
  626.       notify(player,"------------  Queue Done  ------------");
  627.       notify(player, 
  628.          tprintf(
  629.  "Totals: Player...%d/%d   Object...%d/%d   Wait...%d/%d  Semaphore...%d/%d", 
  630.              pq, tpq, oq, toq, wq, twq, sq, tsq));
  631.   }
  632. }
  633.  
  634. void do_halt(owner, ncom, victim)
  635.     dbref owner;
  636.     char *ncom;
  637.     dbref victim;
  638. {
  639.   BQUE *tmp, *trail = NULL, *point, *next;
  640.   int num = 0;
  641.   dbref player;
  642.  
  643.   if (victim == NOTHING)
  644.     player = owner;
  645.   else
  646.     player = victim;
  647.  
  648.   quiet_notify(Owner(player), "Halted.");
  649.  
  650.   for (tmp = qfirst; tmp; tmp = tmp->next)
  651.     if (((tmp->player == player) || (Owner(tmp->player) == player))
  652.     && !Immortal(tmp->player)) {
  653.       num--;
  654.       giveto(player, QUEUE_COST);
  655.       tmp->player = 0;
  656.     }
  657.   for (tmp = qlfirst; tmp; tmp = tmp->next)
  658.     if (((tmp->player == player) || (Owner(tmp->player) == player))
  659.     && !Immortal(tmp->player)) {
  660.       num--;
  661.       giveto(player, QUEUE_COST);
  662.       tmp->player = 0;
  663.     }
  664.  
  665.   /* remove wait q stuff */
  666.   for (point = qwait; point; point = next) {
  667.     if (((point->player == player) || (Owner(point->player) == player))
  668.     && !Immortal(point->player)) {
  669.       giveto(player, QUEUE_COST);
  670.       if (trail)
  671.         trail->next = next = point->next;
  672.       else
  673.         qwait = next = point->next;
  674.       free_qentry(point);
  675.     } else
  676.       next = (trail = point)->next;
  677.   }
  678.  
  679.   /* clear semaphore queue */
  680.  
  681.   for (point = qsemfirst, trail = NULL; point; point = next) {
  682.     if (((point->player == player) || (Owner(point->player) == player)) &&
  683.     !Immortal(point->player)) {
  684.       giveto(player, QUEUE_COST);
  685.       if (trail)
  686.     trail->next = next = point->next;
  687.       else
  688.     qsemfirst = next = point->next;
  689.       if (point == qsemlast)
  690.     qsemlast = trail;
  691.       add_to_sem(point->sem, -1);
  692.       free_qentry(point);
  693.     } else
  694.       next = (trail = point)->next;
  695.   }
  696.  
  697.   if (Owner(player) == player)
  698.     (void) atr_add(player, "QUEUE", "", GOD, NOTHING);
  699.   else
  700.     add_to(player, num);
  701.  
  702.   if (*ncom)
  703.     parse_que(player, ncom, player);
  704. }
  705.  
  706. void do_halt1(player, arg1, arg2)
  707.   dbref player;
  708.   const char *arg1;
  709.   const char *arg2;
  710. {
  711.   dbref victim;
  712.   if (*arg1 == '\0')
  713.     do_halt(player, "", player);
  714.   else {
  715.     init_match(player, arg1, NOTYPE);
  716.     match_neighbor();
  717.     match_possession();
  718.     match_me();
  719.     match_absolute();
  720.     match_player();
  721.     if ((victim = noisy_match_result()) == NOTHING)
  722.       return;
  723.     if (!Owns(player, victim) && !HaltAny(player)) {
  724.       notify(player, "Permission denied.");
  725.       return;
  726.     }
  727.     /* if not player and no new command provided, set it HALT */
  728.     if ((Typeof(victim) != TYPE_PLAYER) && (*arg2 == '\0')) {
  729.       Flags(victim) |= HALT;
  730.     }
  731.     if (Owner(victim) != player) {
  732.       if (Typeof(victim) == TYPE_PLAYER) {
  733.     notify(player, tprintf("All objects for %s have been halted.",
  734.                    Name(victim)));
  735.     notify(victim, tprintf("All of your objects have been halted by %s.",
  736.                    Name(player)));
  737.       } else {
  738.      notify(player, tprintf("Halted: %s's %s(#%d)", 
  739.                    Name(Owner(victim)), Name(victim),
  740.                    victim));
  741.      notify (Owner(victim),
  742.            tprintf("Halted: %s(#%d), by %s", Name(victim),
  743.                victim, Name(player)));
  744.       }
  745.     } else {
  746.       if (victim == player)
  747.      notify(player, "All of your objects have been halted.");
  748.       else
  749.      notify(player, tprintf("Halted: %s(#%d)", Name(victim), victim));
  750.     }
  751.     do_halt(player, arg2, victim);
  752.   }
  753. }
  754.  
  755. void do_allhalt(player)
  756.     dbref player;
  757. {
  758.   dbref victim;
  759.   if (!HaltAny(player)) {
  760.     notify(player, "You do not have the power to bring the world to a halt.");
  761.     return;
  762.   }
  763.   for(victim = 0;victim <db_top; victim++) {
  764.     if(Typeof(victim) == TYPE_PLAYER) {
  765.       notify(victim,tprintf("Your objects have been globally halted by %s",
  766.                 Name(player)));
  767.       do_halt(victim, "", victim);
  768.     }
  769.   }
  770. }
  771.